package org.raymond.icloud.apis.admin.service.fallbackFactory;

import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.raymond.icloud.apis.admin.service.ITSysUserServiceApi;
import org.raymond.icloud.apis.admin.vo.LoginRequestVO;
import org.raymond.icloud.apis.admin.vo.UserInfoVO;
import org.raymond.icloud.apis.admin.vo.entity.SysUserVO;
import org.raymond.icloud.common.core.bean.PageBean;
import org.raymond.icloud.common.core.model.Result;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class ITSysUserServiceFallbackFactory implements FallbackFactory<ITSysUserServiceApi> {
    @Override
    public ITSysUserServiceApi create(Throwable throwable) {
        final String error = throwable.getMessage();
        log.error(error, throwable);
        return new ITSysUserServiceApi() {
            @Override
            public Result create(SysUserVO vo) {
                return Result.error(error);
            }

            @Override
            public Result getByUsername(String username) {
                return Result.error(error);
            }

            @Override
            public Result update(SysUserVO vo) {
                return Result.error(error);
            }

            @Override
            public Result delete(SysUserVO vo) {
                return Result.error(error);
            }

            @Override
            public Result list(PageBean pageBean) {
                return Result.error(error);
            }

            @Override
            public Result login(LoginRequestVO loginVO) {
                return Result.error(error);
            }

            @Override
            public Result<UserInfoVO> current() {
                return Result.error(error);
            }

            @Override
            public Result logout() {
                return Result.error(error);
            }
        };
    }
}
